<div ng-controller="storeManageCtrl">
    <ol class="breadcrumb">
        <li><a href="javascript:void(0)">基础数据维护</a></li>
        <li>门店管理</li>
    </ol>
    <div class="content-container">
        <div class="query">
            <div class="row">
                <form>
                    <div class="col-lg-2" select-search my-list="brands" select-value="conditions.select_brand" key="name" placeholder="请选择品牌名称">
                    </div>
                    <div class="col-lg-2">
                        <div class="input-group input-group-sm">
                            <input type="text" class="form-control" ng-model="conditions.name" placeholder="店面名称">
                        </div>
                    </div>
                    
                    <div class="col-lg-1">
                        <div class="input-group input-group-sm text-right">
                            <button class="btn btn-primary query-btn" ng-click="query()">查询</button>
                        </div>
                    </div>
                    <div class="col-lg-1">
                        <div class="input-group input-group-sm text-right">
                            <button class="btn btn-success query-btn" ng-click="add()">添加</button>
                        </div>
                    </div>
                    <div class="col-lg-1">
                        <div class="input-group input-group-sm text-right">
                            <button class="btn btn-default query-btn" ng-click="clearQuery()">清除</button>
                        </div>
                    </div>
                    <div class="col-lg-1">
                        <div class="input-group input-group-sm text-right">
                            <button class="btn btn-info query-btn" onclick="document.getElementById('uploader').click()">导入</button>
                        </div>
                    </div>
                    <input type="file" nv-file-select  uploader="uploader" id="uploader" class="hidden" name="file"/>
                    
                </form>
            </div>
        </div>
        <div class="row page-result" ng-show="data.length > 0">
            <div class="col-lg-6">
                符合您的查询结果共有
                <label class="text-danger" ng-bind="total"></label>条
            </div>
            <div class="col-lg-6">
                <div class="pagination-size">
                    <select ng-change="changePageSize()" class="form-control input-sm" ng-options="option.name for option in page_size_arr track by option.value" ng-model="page_size">
                    </select>
                </div>
                <ul uib-pagination total-items="total" ng-model="conditions.page" max-size="5" class="pagination-sm pull-right" boundary-link-numbers="true" previous-text="上一页" next-text="下一页" items-per-page="conditions.rows" ng-change="query()"></ul>
            </div>
        </div>
        <div class="datagrid">
            <table class="table table-bordered" ng-show="data.length > 0">
                <tr>
                    <th style="width:5%;">序号</th>
                    <th style="width:13%;">品牌名称</th>
                    <th style="width:15%;">店面名称</th>
                    <th style="width:10%;">店面简称</th>
                    <th style="width:10%;">所属城市</th>
                    <th style="width:12%;">地址</th>
                    <th style="width:10%;">客户经理</th>
                    <th style="width:25%;">操作</th>
                </tr>
                <tr ng-repeat="key in data" ng-click="selectRow(key)" ng-class="{'bg-info' : key.selected}">
                    <td>{{$index+1+(conditions.page-1)*conditions.rows}}</td>
                    <td>{{key.brandName}}</td>
                    <td>{{key.name}}</td>
                    <td>{{key.sortName}}</td>
                    <td>{{key.cityName}}</td>
                    <td>{{key.address}}</td>
                    <td>{{key.adminName}}</td>
                    <td>
                        <button class="btn btn-success btn-sm" ng-click="update(key)"><span class="glyphicon glyphicon-pencil top-2 right-2"></span>修改</button>
                        <button class="btn btn-danger btn-sm" ng-click="delete(key.id)"><span class="glyphicon glyphicon-remove top-2 right-2"></span>删除</button>
                        <!-- <button class="btn btn-primary btn-sm" ng-click="detail(key)"><span class="glyphicon glyphicon-glass top-2 right-2"></span>设置费率</button> -->
                    </td>
                </tr>
            </table>
            <div ng-show="data.length == 0" class="alert alert-warning">
                <span class="glyphicon glyphicon-info-sign"></span>&nbsp;查无相关数据，请重新查询！
            </div>
        </div>
    </div>
    <div alert title="alert.title" content="alert.content" open="alert.open"></div>
</div>
<!-- end controller -->
<script type="text/ng-template" id="detail.html">
<div class="modal-header">
     <button type="button" class="close" ng-click="cancel()"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
    <h3 class="modal-title" id="modal-title">设置费率</h3>
</div>
<form name="form" novalidate ng-submit="ok(form.$valid)">
<div class="modal-body" id="modal-body">
    <table class="table table-bordered text-center">
        <thead>
            <tr class="success">
                <td width="45%">车辆型号</td>
                <td width="15%">客户费率(%)</td>
                <td width="20%">经销商费率(%)</td>
                <td width="20%">厂家费率(%)</td>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="store in store_detail">
                <!-- <td><input type="text" class="form-control" ng-model="store.carName"></td> -->
                <td>
                    <div class="col-md-12" form-search my-list="car_list" select-value="store.car" select-id="store.carId" key="name" placeholder="请选择车辆型号" ng-style="{'z-index':900-$index}">
                      
                    </div>
                    <p ng-show="store.notHas" class="invalid" style="background-color: #FFF;">请选择车辆型号</p> 
                </td>
                <td><input type="number" class="form-control" ng-model="store.clientRate" name="clientRate_0" required>
                <p ng-show="form.clientRate_0.$invalid  && form.clientRate_0.$dirty" class="invalid">请填写客户费率</p></td>
                <td><input type="number" class="form-control" ng-model="store.dealerRate" name="dealerRate_0" required>
                <p ng-show="form.dealerRate_0.$invalid  && form.dealerRate_0.$dirty" class="invalid">请填写经销商费率</p></td>
                <td><input type="number" class="form-control" ng-model="store.venderRate" name="venderRate_0" required>
                <p ng-show="form.venderRate_0.$invalid  && form.venderRate_0.$dirty" class="invalid">请填写厂家费率</p></td>
            </tr>
        </tbody>
    </table>
</div>
<div class="modal-footer">
    <button class="btn btn-primary" type="submit" ng-disabled="form.$invalid">确定</button>
    <button class="btn btn-default" type="button" ng-click="cancel()">取消</button>
</div>
</form>
</script>

<script type="text/ng-template" id="add.html">
<div class="modal-header">
     <button type="button" class="close" ng-click="cancel()"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
    <h3 class="modal-title" id="modal-title">门店基本信息添加</h3>
</div>
<form name="form" novalidate ng-submit="ok(form.$valid)">
<div class="modal-body" id="modal-body">
    <div class="form-horizontal">
        <div class="form-group">
            <span class="col-sm-3 remove-padding control-label"><em class="text-require">*</em>品牌名称：</span>
            <div class="col-sm-9" form-search my-list="brands" select-value="store.select_brand" select-id="store.brandId" key="name" placeholder="请选择品牌名称">
            </div>
        </div>
        <div class="form-group user-role clearfix">
            <span class="col-sm-3 remove-padding control-label"><em class="text-require">*</em>门店车型：</span>
            <div class="col-sm-9" >
                <div class="col-sm-3" ng-repeat="store in store_list">
                    <div class="select-box">
                        <span ng-class="{'unselect': !store.checked, 'select': store.checked}" ng-click="toggleStore(store)"></span>
                    </div>
                    {{store.name}}
                </div>
            </div>
        </div>
        <div class="form-group">
            <span class="col-sm-3 remove-padding control-label"><em class="text-require">*</em>店面名称：</span>
            <div class="col-sm-9">
                <input type="text" class="form-control" ng-model="store.name" placeholder="店面名称" name="name" required>
                <p ng-show="form.name.$invalid  && form.name.$dirty" class="invalid">请填写店面名称</p>
            </div>
        </div>
        <div class="form-group">
            <span class="col-sm-3 remove-padding control-label"><em class="text-require">*</em>店面简称：</span>
            <div class="col-sm-9">
                <input type="text" class="form-control" ng-model="store.sortName" placeholder="店面简称" name="sortName" required>
                <p ng-show="form.sortName.$invalid  && form.sortName.$dirty" class="invalid">请填写店面简称</p>
            </div>
        </div>
        <div class="form-group">
            <span class="col-sm-3 remove-padding control-label"><em class="text-require">*</em>所属城市：</span>
            <div class="col-sm-9">
                <select class="form-control" ng-model="store.cityId" name="cityId" required>
                        <option value="">请选择</option>
                        <option value="{{key.value}}" ng-repeat="key in citys">{{key.keyword}}</option>
                </select>
                <div ng-show="form.cityId.$dirty && form.cityId.$invalid" class="invalid">请选择所属城市</div>
            </div>
        </div>
        <div class="form-group">
            <span class="col-sm-3 remove-padding control-label"><em class="text-require">*</em>店面地址：</span>
            <div class="col-sm-9">
                <input type="text" class="form-control" ng-model="store.address" placeholder="店面地址" name="address" required>
                <p ng-show="form.address.$invalid  && form.address.$dirty" class="invalid">请填写店面地址</p>
            </div>
        </div>
        <div class="form-group">
            <span class="col-sm-3 remove-padding control-label"><em class="text-require">*</em>客户经理：</span>
            <div class="col-sm-9" form-search my-list="users" select-value="store.select_user" select-id="store.adminId" key="name" placeholder="请填写客户经理" style="z-index: 888;">
            </div>
            <!-- <div class="col-sm-9">
                <input type="text" class="form-control" ng-model="store.adminId" placeholder="客户经理" name="adminId" required>
                <p ng-show="form.adminId.$invalid  && form.adminId.$dirty" class="invalid">请填写客户经理</p>
            </div> -->
        </div>
    </div>
</div>
<div class="modal-footer">
    <button class="btn btn-primary" type="submit" ng-disabled="form.$invalid || !store.select_brand.id || !store.select_user.id">确定</button>
    <button class="btn btn-default" type="button" ng-click="cancel()">取消</button>
</div>
</form>
</script>